package com.shyroke.coineye.utils;



import java.util.HashMap;
import java.util.Map;

public class CommonUtils {

    /**
     * 切割获取市值和总量
     * @param supply_value
     * @return
     */
    public static Map<String,String> splitBySupplyAndValue(String supply_value){
        Map<String,String> resultMap = new HashMap<>();

        if(supply_value!=null && supply_value!=""){

            int startIndex = supply_value.indexOf("(");
            int endIndex = supply_value.indexOf(")");

            resultMap.put("supply",supply_value.substring(0,startIndex));
            resultMap.put("value",supply_value.substring(startIndex+1,endIndex));
        }

        return resultMap;
    }

    /**
     * 切割价格和跌涨幅的字符串
     * @param price_updown
     * @return
     */
    public static Map<String,String> splitByPriceAndUpDown(String price_updown) {
        Map<String,String> resultMap = new HashMap<>();

        if( price_updown != null && price_updown != ""){

            int startIndex = price_updown.indexOf("(");
            int endIndex = price_updown.indexOf(")");


            resultMap.put("price",price_updown.substring(0,startIndex).split("@")[0]);
            resultMap.put("updown",price_updown.substring(startIndex+1,endIndex));

        }

        return resultMap;
    }
}
